Python 3 support

`basestring` doesn't exist in Python 3 so I added a simple shim I found on SO.