Use six to make xrange work across python 2 and 3

One step at a time. This changes all xrange to six.moves.range which is guaranteed to work on python 2 and python 3.