Improved handling of image upload.