from PIL import Image, ImageDraw


def draw_ellipse(image, xy, a, b, facecolor, edgecolor):
    """Improved ellipse drawing function, based on PIL.ImageDraw."""
    mask = Image.new( size=image.size, mode='RGBA')
    draw = ImageDraw.Draw(mask)
    draw.ellipse([xy[0]-a, xy[0]-b, xy[1]+a, xy[1]+b],
                     fill=tuple(facecolor), outline=tuple(edgecolor))
    mask = mask.resize(image.size, Image.LANCZOS)
    mask = mask.rotate(45)
    image.paste(mask, mask=mask)
    return image