I figured it out. I was turning the entire file I was writing to into a png just for the background image which messed up everything that came after. I saved the File object containing the background image instead and that seems to work.