Moved IM_MALLOC/IM_FREE/etc. to IO structure members one can set at runtime.