def METHOD_NAME(pixmap, path, original_path):
    """Write pixmap to disk.
    See write_pixmap for the args description.
    """
    # Get pixmap type
    _, ext = os.path.splitext(path)
    # First create temporary file and then move it to avoid race conditions
    handle, filename = tempfile.mkstemp(suffix=ext)
    os.close(handle)
    pixmap.save(filename)
    # Best-effort copy metadata info from original file to new file
    try:
        imutils.metadata.MetadataHandler(original_path).copy_metadata(filename)
    except imutils.metadata.MetadataError:
        pass
    shutil.move(filename, path)
    # Check if valid image was created
    if not os.path.isfile(path):
        raise WriteError("File not written, unknown exception")
    if not files.is_image(path):
        os.remove(path)
        raise WriteError("No valid image written. Is the extention valid?")