clean up and adde magic flip_y function, got from https://github.com/mapbox/mbutil/blob/master/mbutil/util.py