fix: also swap image allocation functions when swapping image memory