config.py: Make the code clearer for _sub_str()
Py3 compatibility fixes

Handle possible utf-16 characters and ensure unicode strings
Some .splits() would TypeError, wrap them with _unicode() to ensure correct type.