fix translation to/from Google,TMS tile formats

Web-mapping tools expect Google tile coordinates while all the
processing is performed in terms of TMS tile coordinates. Translate to
Google coordinates for generating output files, and convert back to
TMS for comparison processing (as this is the natural format for
gdal2tiles). From gdal2tiles:

"""
What is the difference between TMS and Google Maps/QuadTree tile name convention?

  The tile raster itself is the same (equal extent, projection, pixel size),
  there is just different identification of the same raster tile.
  Tiles in TMS are counted from [0,0] in the bottom-left corner, id is XYZ.
  Google placed the origin [0,0] to the top-left corner, reference is XYZ.
  Microsoft is referencing tiles by a QuadTree name, defined on the website:
  http://msdn2.microsoft.com/en-us/library/bb259689.aspx
"""