Transform to compute the mean image from templates and write as image