catch IOError loading templates

can be raised sometimes (Windows) instead of TemplateNotFound.

Also turn other unhanded exceptions into warnings, rather than raising.
don't try template names we know to be invalid

if template_file is empty, only one choice makes sense: module name
Merge pull request #3878 from minrk/ioerror

minor template loading cleanup