def _write(self, img_array, verbose=False, **kwargs):
        """Write image data to a JP2/JPX/J2k file.  Intended usage of the
        various parameters follows that of OpenJPEG's opj_compress utility.

        This method can only be used to create JPEG 2000 images that can fit
        in memory.
        """
        if re.match("0|1.[0-4]", version.openjpeg_version) is not None:
            msg = ("You must have at least version 1.5 of OpenJPEG "
                   "in order to write images.")
            raise RuntimeError(msg)

        self._determine_colorspace(**kwargs)
        self._populate_cparams(img_array, **kwargs)

        if opj2.OPENJP2 is not None:
            self._write_openjp2(img_array, verbose=verbose)
        else:
            self._write_openjpeg(img_array, verbose=verbose)