PIL';utf-8';编解码器可以';t解码位置0中的字节0x89:无效的开始字节

PIL';utf-8';编解码器可以';t解码位置0中的字节0x89:无效的开始字节,utf-8,python-imaging-library,discord.py,decode,python-unicode,Utf 8,Python Imaging Library,Discord.py,Decode,Python Unicode,我正在将两个图像粘贴在一起,作为我的bot的Discord文件使用,但每当我尝试将完成的图像数据从PIL和BytesIO馈送到Discord时,就会出现这样一个奇怪的错误:UnicodeDecodeError:“utf-8”编解码器无法解码位置0:无效起始字节中的字节0x89 这是我的代码(或相关的块): async with aiohttp.ClientSession() as session: async with session.get(avurl) as second_image

我正在将两个图像粘贴在一起,作为我的bot的Discord文件使用,但每当我尝试将完成的图像数据从PIL和BytesIO馈送到Discord时,就会出现这样一个奇怪的错误:UnicodeDecodeError:“utf-8”编解码器无法解码位置0:无效起始字节中的字节0x89

这是我的代码(或相关的块):

async with aiohttp.ClientSession() as session:
    async with session.get(avurl) as second_image:
        image_bytes = await second_image.read()

with Image.open(BytesIO(image_bytes)).convert("RGB") as first_image:
    output_buffer = BytesIO()
    first_image.save(output_buffer, "png")
    output_buffer.seek(0)

async with aiohttp.ClientSession() as session:
    async with session.get("https://i.imgur.com/dNS0WJO.png") as second_image:
        image_bytes = await second_image.read()

with Image.open(BytesIO(image_bytes)) as second_image:
    output_buffer = BytesIO()
    second_image.save(output_buffer, "png")
    output_buffer.seek(0)

first_image.paste(second_image, (0, 0))
buf = io.BytesIO()
first_image.save(buf, "png")
first_image = first_image.getvalue()
buf = buf.getvalue()
file = discord.File(fp=buf, filename="pfp.png")