in display_signature()
there are calls to
imagepng($image);
imagedestroy($image);
that are needless, since the image is already created you can just do this:
$fp = fopen($folder . $imagename, 'rb'); # stream the image directly from the cachefile
fpassthru($fp);
instead of reprocessing it thru GD. (this was taken from PHP.net here: http://php.net/manual/en/function.imagepng.php)
Also we had a bug where ob_start had previously been called. So we needed to clean the output buffer first.
this will clean out all the buffers:
$levels = ob_get_level();
for ($i=0; $i<$levels; $i++)
ob_end_clean();