fix(system): write all files atomically

cc @marineam