<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_image(filename, image):
 """ Write image data to PNG, JPG file :param filename: name of PNG or JPG file to write data to :type filename: str :param image: image data to write to file :type image: numpy array """

    data_format = get_data_format(filename)
    if data_format is MimeType.JPG:
        LOGGER.warning('Warning: jpeg is a lossy format therefore saved data will be modified.')
    return Image.fromarray(image).save(filename)