'Convenience method to set the internal image from a stream of raw data
:param data: Bytes to be set
:param rawmode: The rawmode to be used for the decoder. If not specified,
it will default to the mode of the image
:returns: None'

def set_as_raw(self, data, rawmode=None):

    if (not rawmode):
        rawmode = self.mode
    d = Image._getdecoder(self.mode, 'raw', rawmode)
    d.setimage(self.im, self.state.extents())
    s = d.decode(data)
    if (s[0] >= 0):
        raise ValueError('not    enough    image    data')
    if (s[1] != 0):
        raise ValueError('cannot    decode    image    data')
