fix crash when uploading images