update Template Loader with 'with' statement

As title.
Using with statement to meet Python code standard.