consider calling #update_metadata here if mode == 'w' instead of calling it explicitly