problem in pyexiv2

I have a problem with pyexiv2.
i am trying to apply xmp file to image:

import pyexiv2
# Upload image
image = pyexiv2.Image('image.jpg')
# Load XMP data from preset file
xmp_data = open('filtered.xmp', 'r').read()
# Apply XMP data to image
image.modify_raw_xmp(xmp_data)
image.write()

but i get this error :
AttributeError: ‘Image’ object has no attribute ‘write’

There is no write method, but there is a write_to_file method that takes a path as an argument.