fixed bugs in image upload