lock the tiles table, insert and return MAX id in queries.py
store sha1 hash of images instead of the b64 data