Slight modifications to the image upload logic