Fix for copying metadata flags
Merge pull request #6514 from takluyver/atomic-writing-chflags-fix

Fix for copying metadata flags