Fix downcasting warnings in the jpeg2000 plugin.
Make sure the jpeg2000 event manager transfer object remains valid.

The contents of the stack-allocated event manager structure created in the helper function are undefined after calling it. MSVC was overwritting those values, causing segfaults during the decoding.