Saving files: now first save to a temporary file and then overwrite the original file (closes #523).