<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def convert(self):
 """Yields xterm color codes for each pixel in image """

        (width, height) = self.img.size
        bgcolor = utils.term.bgcolor
        self.img.load()
        for y in range(height):
            for x in range(width):
                rgba = self.img.getpixel((x, y))
                if len(rgba) == 4 and rgba[3] == 0:
                    yield None
                elif len(rgba) == 3 or rgba[3] == 255:
                    yield xterm256.rgb_to_xterm(*rgba[:3])
                else:
                    color = grapefruit.Color.NewFromRgb(
                        *[c / 255.0 for c in rgba])
                    rgba = grapefruit.Color.AlphaBlend(color, bgcolor).rgb
                    yield xterm256.rgb_to_xterm(
                        *[int(c * 255.0) for c in rgba])
            yield "EOL"