writing tile to db