compatibility with python 3.4

Added some casts to int since the result of divisions in Python 3 is  automatically cast to float whereas in Python 2 they are still integers (maybe math.floor could be used but it could result in different behaviour).

Heapq breaks in Python 3 if you push a duplicate on it i.e. push(heap, (0, 0.0, <Quad>)), push(heap, (0, 0.0, <Quad>)) breaks it since there is no implementation of __lt__ in Quad. I added a counter (0, 0.0, counter, <Quad>) which ensures uniqueness of the tuple and preserves insertion order.