Python 3 compatibility of tests
Begin python3 encode fixes, not yet finished.