added python3 support, various improvements

this time: using tabs!

all five commits should be independently mergable, so feel free to cherry-pick if you don't like one of them.