When reading the map file, use Mako-specific classes only if they are imported

The Mako classes 'Template' and 'MakoException' are imported at the top of the module.

A debug message is logged if they are not installed, but execution continues until the read() method where the Template and MakoException classes are used without being defined, causing an uncaught NameError.

The patch includes a MAKO_AVAILABLE variable which is set to True/False depending on the result of the mako imports. This variable is then used to determine whether or not to run the mako-related code in the read() method.