Better handling of IO errors when saving