visualization code doodles.
fixed image conversion function (which was broken)