Which country is responsible for prosecution if a crime is committed over international waters?
Broadly the legal constructs that apply here are essentially the same as for sailing vessels - in other words when you're outside the jurisdiction of any given nation the laws of the country the vessel is registered in apply, and the captain is the one who makes the decisions.  

More specifically once you enter the airspace of a nation that nations laws also apply (the same as crossing the boundary from international waters to the territorial waters of a nation - by entering their territory you're obligated to abide by their laws).



If the above doesn't seem murky enough, it's because it actually gets a lot more complicated than that when you start considering all the laws various countries may pass (and subsequently attempt to enforce).

Consider for example The "Special Aircraft Jurisdiction of the United States" in which the US claims jurisdiction over any aircraft in our airspace, or any aircraft in flight which is intending to land on our soil (as long as they actually do land on our soil).

As with most areas of international law going to far down this rabbit hole will likely lead to madness.
For practical purposes you can assume that four bodies of law will govern every flight: 


The laws of the country from which the aircraft is departing.
The laws of any country whose airspace the aircraft transits, while in that airspace.
The laws of the country in which the aircraft is landing.
The laws of the country to which the aircraft is registered.


...and if you can avoid breaking any laws in those 4 categories you'll be pretty well covered for most circumstances.