def mix_images(background_img, foreground_img):
    """paste an image on top of another image
    Args:
        background_img: pillow image in background
        foreground_img: pillow image in foreground

    Returns:
        pillow image
    """
    background_img = background_img.convert('RGBA')
    foreground_img = foreground_img.convert('RGBA')

    img_w, img_h = foreground_img.size
    bg_w, bg_h = background_img.size
    offset = ((bg_w - img_w) // 2, (bg_h - img_h) // 2)
    background_img.paste(foreground_img, offset, mask=foreground_img)

    return background_img