Programatically determine PostGIS template

The name for the PostGIS template can be changed by setting the
POSTGIS_TEMPLATE setting. This commit allows for that.

Since PostGIS 2.0, the template is optional. This commit consequently
only issues the SQL CREATE statement if a template is used.

Fixes #489.

Tox tests pass on my machine, and I've confirmed I can again issue a ``reset_db`` statement for a PostGIS 2.1 database.