Use a dynamically allocated buffer to remove size restriction on template files