first steps towards Python 3 (but major refactoring around str/bytes might be needed)