I have had this question for a long time. For example, if I wire 50M USD from China to the US, does the Chinese bank physically deliver 50M USD cash to the US bank? or is it just changing a number in the computer? If it's done digitally, then how does the US bank ensure that the Chinese bank isn't just creating USD out of thin air?
The bank in china has to have an account at an intermediary bank, and order a transfer from that account to the account of the US bank. Therefore the chinese bank needs to have the dollars.
For large currency transactions, the big banks go through an intermediary called CLS. Both sides to a transaction transfer funds (in form of central bank deposits) to the CLS group. Then simultaneously these are transferred to the respective parties. Or if one side fails to deliver CLS returns the funds of the other party. See http://en.wikipedia.org/w/index.php?title=CLS_Group .
I am not expert but china has U.S. Treasury Bonds, so both sides does know how much bond china has and how much bonds getting converted to USD. Its all build on trust, otherwise start to stack sandbags.