Fix imports and string types for work with Python 3