Fixed memory leaks

Fixed 4 memory leaks and 1 crash.
Further spit & polish

- _get_template_from_file doesn't close fh as per comments
- _get_template_from_file does block reads
- _get_template_from_file null terminates
- changed template to tmpl since it confuses a c++ compiler even in
extern C
- another mem leak in  _process_modifiers
- added extern C
Merge pull request #5 from fireice-uk/master

Bug, mem leaks and other minor fixes