<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def convert_images(image_list, image_format="png", timeout=20):
 """Convert images from list of images to given format, if needed. Figure out the types of the images that were extracted from the tarball and determine how to convert them into PNG. extracted from the tarball in step 1 :param: image_format (string):
 which image format to convert to. (PNG by default) :param: timeout (int):
 the timeout value on shell commands. image files when all have been converted to PNG format. """

    png_output_contains = 'PNG image'
    image_mapping = {}
    for image_file in image_list:
        if os.path.isdir(image_file):
            continue

        if not os.path.exists(image_file):
            continue

        cmd_out = check_output(['file', image_file], timeout=timeout)
        if cmd_out.find(png_output_contains) > -1:
            # Already PNG
            image_mapping[image_file] = image_file
        else:
            # we're just going to assume that ImageMagick can convert all
            # the image types that we may be faced with
            # for sure it can do EPS->PNG and JPG->PNG and PS->PNG
            # and PSTEX->PNG
            converted_image_file = get_converted_image_name(image_file)
            try:
                convert_image(image_file, converted_image_file, image_format)
            except (MissingDelegateError, ResourceLimitError):
                # Too bad, cannot convert image format.
                continue
            if os.path.exists(converted_image_file):
                image_mapping[converted_image_file] = image_file

    return image_mapping