cpd: fix #1144 CPD encoding argument has no effect

Make sure the encoding is set before creating the renderer