Made it so that MATLAB compatible userblock is put in HDF5 file before data is written as opposed to after (fixes bug where the file becomes not MATLAB compatible if an exception occurs).