fixed php bug and improved image quality