Fixed the problem with flipped y-coordinate. Added function to join the grid data which is in pieces when stored in mbtiles file