def METHOD_NAME(device_id, input_sof, kernel_hex):
    pof_file = create_pof(input_sof, kernel_hex)
    with tempfile.NamedTemporaryFile(suffix=".cdf") as temp_cdf:
        dname, fname = os.path.split(pof_file.name)
        t = string.Template(quartus_pgm_template)
        cdf = t.substitute(POF_DIR=dname, POF_FILE=fname)
        temp_cdf.write(bytes(cdf, 'UTF-8'))
        temp_cdf.flush()
        cmd = ["quartus_pgm", "-c", device_id, temp_cdf.name]
        try:
            subprocess.check_output(cmd)
        except subprocess.CalledProcessError as cpe:
            sys.exit(cpe.output.decode("utf-8") +
                     "\nFailed to flash image")
    pof_file.close()