template matching for python