first working version of template_match.py
Minor bug fixes to template_matching.py