Work done by the System
Well, think of a gas that is expanding against a piston shown below:

We want to find the total work which is given by: $$w = F\Delta d$$ So we need to know what is the force that is applied by the gas onto the piston. To do this, we must realise that, the force that is stopping the gas from expanding freely into the atmosphere is the external atmospheric pressure. It is this pressure which is pushing downwards onto the gas, preventing it from expanding. Therefore, the force that is required for the gas to expand must be equal to the total pressure pushing down it and has nothing to do with its internal pressure.

Consider this example. I want to push a box across my room which is covered in carpet. To move the box, obviously I need to apply a force to it. The force that I need to apply to must be equal or greater than the resisting force which is the friction between the box and carpet. This force that is required has nothing to do with the speed of the box. 

So now that we know the force, we get that $$w = -p_{ex}A\Delta d$$ but the area times the displacement is actually equal to the volume, therefore we get: $$w =-p_{ex}\Delta V$$

So, as you can see, we have derived the equation for work done by a gas. The main thing that you need to recognise is that the internal pressure is irrelevant when considering the force required for the gas to expand. All you need to consider is the force that is preventing it from expanding which is the external pressure.