Catch IOErrors and OSErrors when creating Images

They can happen if the disk is full or the user is not allowed to access
the folder where tempfile.TemporaryFile wants to create the file.