Bug fixes to image upload