Length encoding using pack 'V'

This saves us from doing the bit shifting in our code.  This merge request includes tests and some other changes...