Make the kernel image format parametric instead of a chain of if/elses