Added logic to support table 'tiles' as a view or as a table. Force .mbtiles as extention upon creation.

According the the mbtiles specification, 'tiles' can be a view or table.
- normally it is a view as implemented (tilemill)
- gdal however creates a table, thus this must be checked and the insert logic adapted.

An exception has been caught if the database has been closed while the class was still inside the insert logic. 

Upon creation of the database-file, the given name will receive '.mbtiles' as extension in case some other extension was given.