Revised character encoding of metadata.

Had a bit of a mix of utf-8 and latin-1 encoding and decoding of
metadata text strings. XMP is easy - it's always utf-8, EXIF and IPTC
are less well defined. Now the encoding used in each file is detected as
the data is read, and the same encoding used when data is written.