Fix and enhance the determine_output_formats() method for tools.  Tool configs that define multiple <when> tags will now return the correct format since the check stops as soon as the format is found, and the method will now check attributes of the HDA's metadata as well as its immediate attributes.
Merge with 3b3eab0aefdf56eca923bb378715573e2cff83df
Change the file_ext attribute of datatypes.images.Jpg() to be 'jpg' instead of 'jpeg' so that dataset.datatype.file_ext == dataset.extension and dataset.datatype.file_ext will be found in datatypes.registry.Registry().datatypes_by_extension.
Unit tests for pull request #568.
Merge.