Converting anything in this way requires a little thinking in advance. You need to analyse the information you are converting and figure out how high and wide it might be. For example, showing a division operation such as:
23
a = --
10
requires first, two 'lines', each of which needs to be high enough to contain characters in the selected font. Secondly a 'line' high enough to contain a separator. The start of the expression "a = " should be positioned centred on the dividing line. The actual calculations would be based on the size of the image you wish to display and the size of the font being used for the characters, so assuming a font 10 px high by 8 px wide we would have something like:
moveto(32, 0) // position X, Y
write("23")
moveto(0, 6)
write("a = ")
moveto(32, 12)
lineto(48, 12)
moveto(32, 14)
write("10")