Pack unpack

Implement `pack()` and `unpack()` (mostly @rgsoda's work) and fix a related bug in `unserialize()`.

Everything works, but it's slow.