Fix .to_string so it always returns a string

In Python 2, this function would return a unicode string, not a string.
This fixes that.  This does not change the behavior on Python 3.

This also simplifies some of the packing logic and makes it behave the
same in Python 2 and 3 using some six functions.