Change vid encoding so that we only encode to base 64 on serialization.

This made some existing logic feel more difficult than it should,
so added enum encoding and encode and decode methods
to make it easier to make encoding transformations.

Added a couple of TODOs - one as a reminder that json deserialisation
is incomplete, the other because I did not understand the code.

Also changed a couple of asserts to runtime checks (more
are needed).
Merge remote-tracking branch 'rogpeppe/001-change-vid-encoding'

* rogpeppe/001-change-vid-encoding:
  Change vid encoding so that we only encode to base 64 on serialization.
Cleanup warnings from merge commit