Implement atomic writes