add: compat.py, prepare for python3 support
use basestring from compat

plus some minor style fix