print ik
</pre>
For MODE 1 images, replace the second-to last loop with:
<pre>
for cl in range(8): # line in character
for y in range(ydim/8):
for x in range(0,xdim,4):
aa=byte_bin(b[x,y*8+cl])[6:]
bb=byte_bin(b[x+1,y*8+cl])[6:]
cc=byte_bin(b[x+2,y*8+cl])[6:]
dd=byte_bin(b[x+3,y*8+cl])[6:]
oo=(aa[1]+bb[1]+cc[1]+dd[1] +
aa[0]+bb[0]+cc[0]+dd[0])
oo=int(oo,2)
data = struct.pack("B", oo)
binfile.write(data)
data = struct.pack("B", 0)
for t in range(48):
binfile.write(data)
</pre>