Save to store.json.tmp before overwriting to store.json.

This should greatly decrease chances of data corruption, at least on NTFS.

Previously, there existed a window during which not all data existed on disk. Reopening the file with the "w" mode would truncate it, meaning that for some time the user data did not exist on the filesystem.

This patch makes the save operation atomic - since the data is written to a temporary file first, and overwriting files by renames is an atomic operation, saving data should be much safer with this change.