Fix #942 - Catch out of memory errors when uploading pictures

Please, double check the error messages i added in this patch.