Process for Making a Flyback Transformer
I like to start such a project with a rough ballpark design.  Looking at the primary side, you want 400 Watts at 24 volts, so your average current is about 16.6 amps.  Round up to 20.  So the current waveform is a sawtooth, with a peak of 40 amps.

Now let's pick a frequency, say 20 kHz. You want the current to ramp up at the rate of 40 amps per 50 microseconds with 24 volts applied, so the inductance of the primary is L=V/Idot = 30 microhenries.  Now you just have to go shopping for gapped ferrite cores that will give you the power handling capability.  If you go to www.mag-inc.com you will find design tables and all kinds of helpful stuff. (I don't work for them, but I have used their cores).

Once you have a core big enough for your power, you have to pick the number of turns and the gap size such that you get the right inductance without saturating the core at the amount of volt-seconds you'll be running.  Then you pick the wire size so that the resistive losses are tolerable.  Then you consider the flyback part of the equation.  When your transistors turn off what voltage will the primary rise to?  Here you're going to find out how expensive and slow transistors are at high voltage.  Then once you know the flyback voltage you divide 40 kV by that and that will give you the ratio of the number of turns on your secondary to the number of turns on your primary.

Now look at the monster you've created.  Will all the turns fit?  Is it too big? If you go to a higher frequency the core gets smaller, the output filter capacitor gets smaller but the transistors start dissipating more heat. Also consider that you'll want to pot the transformer to keep the 40 kV from arcing, which makes it harder to cool your transformer.  Also you'll have to have some kind of circuit adjusting the transistor duty cycle to regulate the output voltage.  Finally you need a design for the output rectifier. You'll want to pay attention to the reverse recovery time of the diodes and make sure the dV/dt you're applying is reasonable.