implement serialisers and readers to write and read HMMs from/to file, respectively.