minimal changes to support python2

Thanks for this handy little program. It seemed a shame to require one to get
Python 3 just to use it, given how few Python 3 features there are in the code,
so I decided to submit this patch to make it work there.