I can't help with building it (maybe someone else here can/will), but in the meantime, REXPaint has a version of this feature built in to it, albeit without character-based dithering. So maybe you could try that.
The instructions are in the manual, Appendix G.
As of now it'll require that you append the "cell size" to the filename to work, so for example converting a regular image will mean appending "_1x1" for pixelwise conversion. (That said, for REXPaint's next release I've updated it to assume pixewise conversion if no cell size is appended, as that will be the most common use case.)
Example: On Windows, you can drop your imagename_1x1.png file in REXPaint's /images/ directory, create a .bat file in the main directory with the following contents
start REXPaint.exe -png2xp:imagename_1x1
then run the .bat file and it'll output your .xp file. Just open/reopen REXPaint to see it.