(Initial) Python 3 support

Marginal support for Python 3, which doesn't have `basestring` (but does have `bytes`). I've also added `long` to the Python 2 primitive types.