You need to change the maximum memory allowed to a php script to run.
For this you need to open your php.ini (location of this file will depend on where php is installed on your machine). In my case php.ini is in /etc/php5/apache2/php.ini
Open /etc/php5/apache2/php.ini
search for memory_limit
change 16M to 32M
save file, you are good to go!