mesh.write_hdf5() fix

Previously failed for case when ```mats=None```.