Resonant state expansion applied to open optical systems