OCaml code corrupts image but changes it