A few more small fixes to the encoder and decoder.

I still need to add some more unit tests to cover the work I'm doing.  Probably
something that writes out a file that is then run by python and validated.
Still figuring out the details.