Copy file metadata in atomic save

Closes gh-6405
Preserve symlinks in atomic writing
Fix typo
Merge pull request #6453 from takluyver/atomic-save-copystat

Copy file metadata in atomic save