'Called from ImageFile to set the core output image for the decoder
:param im: A core image object
:param extents: a 4 tuple of (x0, y0, x1, y1) defining the rectangle
for this tile
:returns: None'

def setimage(self, im, extents=None):

    self.im = im
    if extents:
        (x0, y0, x1, y1) = extents
    else:
        (x0, y0, x1, y1) = (0, 0, 0, 0)
    if ((x0 == 0) and (x1 == 0)):
        (self.state.xsize, self.state.ysize) = self.im.size
    else:
        self.state.xoff = x0
        self.state.yoff = y0
        self.state.xsize = (x1 - x0)
        self.state.ysize = (y1 - y0)
    if ((self.state.xsize <= 0) or (self.state.ysize <= 0)):
        raise ValueError('Size    cannot    be    negative')
    if (((self.state.xsize + self.state.xoff) > self.im.size[0]) or ((self.state.ysize + self.state.yoff) > self.im.size[1])):
        raise ValueError('Tile    cannot    extend    outside    image')
