with open('myfile.tmx', 'w') as f:
    f.write(
        '<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE tmx SYSTEM "tmx14a.dtd">'
        )
ElementTree.ElementTree(tree).write(f, 'utf-8')
How to create <!DOCTYPE> with Python's cElementTree