similar to what mingw is saying, I've gotten rather good rates whenever I've made an ATM withdrawal (such as at a 711 in Japan). I believe the network determines the rate as mingw suggests.
I can't answer for transactions using a debit or credit card or a cash advance from an ATM in a foreign country on a credit card.