In summary, 1031 exchanges in foreign countries can only be used if all properties involved (the relinquished property and the replacement property) are outside of the United States and its territories, and they should only be done in countries with no capital gains taxes.
A Qualified Intermediary, or QI, is an independent third party to the transaction whose function is to prepare the documents necessary to create the exchange, as well as to act as the independent escrow agent for the exchange funds.
This means that you cannot perform a 1031 exchange between a U.S. property and a non-U.S. property. If your relinquished property is located within the United States, then your replacement property must also be located within the United States (or certain U.S. territories) to qualify for 1031 tax deferral.