implement custom image alloc/release functions for encoder (testing required)