Added some error checking on the image upload