Write the binary cache file atomically