Speed up EncodeInt( )

now O(log(n))
Reorder x, y