fixed anerror with writing the the output h5m file