Image writing fixes.