If you attempt to use a file resource with a 'content' parameter pointing at a template, and the template contains binary content, you may get an error like this:
I've reproduced the failure in 2.7.16 and 3.x, though the error messages differ slightly between the two (and also depending on whether you repro via 'apply' or via master/agent run).
I'm attaching the binary file that I'm using to repro. Save it into a directory structure like this:
Add the "modules" directory to your module path and then you can repro with the following manifest:
Note that if you use the 'source' parameter rather than the 'content' parameter (and avoid calling the template function), the manifest can be applied successfully; so the issue is when bringing in binary data as a string.