Switch to mkstemp/atomic_move for writing changes