Template version of entropy codec