Fixing bugs where tiles are drawn in the wrong place.

The simplest way to reproduce one of the bugs this fixes is to zoom out until you see most of the world in the demo page then generate an image.