General image to binary converter