minor code improvements in image related PHP files