python3 support

i am sorry for 1 commit, i tried to divide it into smaller ones, but python 2 tests didn't pass in each.