Fix support for dynamic methods in collect_method_images (). Fixes #12412.