Write co msgs to tmpfile to avoid encoding issues

Fixes #36