fix image writing if not exists on disk