Error handling when uploading images