Does that mean that Nuremberg and Tokyo trials were just a farce?
"No bill of attainder or ex post facto Law shall be passed." - US Constitution Article 1 Section 9 [1]
"No one shall be held guilty of any penal offence on account of any act or omission which did not constitute a penal offence, under national or international law, at the time when it was committed. Nor shall a heavier penalty be imposed than the one that was applicable at the time the penal offence was committed." - United Nations Universal Declaration of human rights. Article 11 [2]
[0] http://www.ihr.org/jhr/v12/v12p167_webera.html
[1] https://www.law.cornell.edu/constitution/articlei#section9
[2] http://www.un.org/en/universal-declaration-human-rights/
In a parallel fashion, WWII's Prisoners Of War (POWs) were renamed DEF by the US ("Disarmed Enemy Forces"), to dodge the Geneva convention about POWs, and some were badly treated (The Wikipedia page has a discussion on the numbers – see "Other Losses").
There is no such thing as black and white.
And Nuremberg trials was famous for doing precisely what gizmo686 described -- charging defendants with "crimes" that were defined as crimes after the fact. https://en.wikipedia.org/wiki/Nuremberg_trials#Criticism
https://en.wikipedia.org/wiki/Jus_gentium
https://en.wikipedia.org/wiki/Hostis_humani_generis
It works in the same manner as unwritten common law does - set by custom and precedent.