Update generate_background_xml.py

write xml to file using context manager