When I export to pdf the local master overrides are exported to pdf. The weird thing is that some are ok and other are not.
After a lot of trial and error, I selected Override All Master Page Items from the pages panel menu. After that it worked, but of course changes to the masterpage are now not applied anymore.
Is there a solution for this?
Yes. Simply don't do local overrides on master pages. You could make another master page for this.