using PIL

fix issue #1 for flipped tiles