Use six for string type detection for improved Python 3 compatibility
Use six for text type for improved Python 3 compatibility