handcode img2bw