Implement atomic save

Ping @fperez, this should avoid issues with corrupted/lost notebooks when the disk is full, though I haven't worked out how to test it just yet.

Closes gh-6254
I'm not sure if this is needed, but other seem to recommend fsyning right before this point to ensure that the data is written to disk; this seems to be possible problem on ext4.

 http://stackoverflow.com/questions/7433057/is-rename-without-fsync-safe