fix compatibility for C89

Move variable declaration to head of block
make parameters const
use variable instead of magic-number
reduce strlen
return 415 when smalllight failed to process image
fix memory leak in processing image by GD and clean up