Support for TileStache's 'safe' layout

This adds support for TileStache's 'safe' directory layout:
http://tilestache.org/doc/#caches

This also corrects grid filenames when writing.