[Issue286] Add support for atomic file renaming

See #286.
Hi,
sorry for the mistake. I've fixed it.