Python 3.x support

I wanted to use this library with Python 3, but because it uses xrange() and implicit integer division (rather than `//` integer division) it doesn't work.

The division changes are perfectly safe, and I believe xrange->range won't introduce any performance issues on Python 2.x, though it may be a slight regression. Changing the function call seemed a little nicer than introducing an xrange alias for Python 3.