fixing template production from 2d histograms