tiff: fix handling of metadata with refcounted frames