Made suggested changes:
OutputImage is now managed by a shared_ptr.
Flags are fixed.