Fixing bugs when writing the dimensions to the HDF5 file