Add a two-stage mechanism to store data on the currently opened datafile
If the chosen path for saving is the same as the path of the current dataset file, then a two-step process is used to avoid HDF5 errors:
- Create a temporary file to store the data.
- After writing is finished, rename the temporary file to the original given path.