Closes #1 - state transitions are now written as integer values

* This should massively speed up write time, there was no need to write
  the whole object for every transition
* Create a seperate output stream that writes a mapping of state to its
  unique integer id
* It is up to the API user to assign integer ids
* Added unit tests