Let's assume I have 100 million Iranian rials in cash. This is very roughly equivalent to something like 1000 Euros. I am in Iran and am traveling to Europe soon. Am I likely to get a better deal if I change my rials into euros in Iran or in Europe?
Large Iranian banks, like Bank-e Melli-ye Iran (BMI), Bank -e- Sepah, Bank Mellat, Bank-e Saaderaat-e Iran (BSI), Bank-e Paasaargad and Bank-e Saamaan (Saamaan Bank), and Beank-e Paarsiaan all have branches outside the country that can be found at their websites. Source: https://en.m.wikivoyage.org/wiki/Iran
You could check with some of the above banks and see whether their rates can compete with those of private exchange offices in Iran.
That said, it's definitely easier to exchange Rial in Iran (not many foreign banks will accept them) and probably you'll get better rates too.
I suggest you contact some banks and exchange offices in Europe and compare their rates (and fees) with the ones on the ground while you're still in Iran.
This post is relatively old and probably you've already exchanged your money but anyway, I'll add more points to what Martin already said, for future travellers:
Where to exchange:
I recommend to exchange your money inside Iran, but in certified exchange offices and not in the banks.
Currency in Iran has been always complicated, and lately, it's got even worse with all the sanctions, and its value being so unstable! As a result, there are plenty of exchange rates (official, merchant, traveller, free market, etc). Banks, usually work with the official rate which is currently around one-third of the free market. They might buy your Euros based on a different rate which is close to that in free market but still less.
Airport regulations for currencies:
You can take up to 10 thousand Dollars (or equivalent) to Iran without any need for declarations [source].
The limit for going abroad is around 5 thousand Euros (or equivalent) and/or 5M IRR (right now equivalent to ~40 Euros) [source].
If you are curious and want to know more, I suggest watching this video by Nick (Indigo Traveller). In his video, he explains the complexity of the Iranian currency and some of the best practices on how to manage that as a foreigner.