Use atomic cache file creation.

Fixes #31.