Here you should do:

    with open(import_filename.replace('.docx', '.html'), 'w') as new_html:
        new_html.write(html)