pdDebug: add support for external library error tracking

FreeImage, specifically
JPEG-2000 exporting: minor improvements

Also, reported some regressions in 3.16.0 to the FreeImage team.
Hopefully they can track down the cause sooner rather than later...
Add callback for internal FreeImage errors

Messages will be rerouted to pdDebug as necessary