Bumblebee Ubuntu 12.04 Workaround [Cannot access secondary GPU - error: XORG NVIDIA(0): No display devices found for this X screen]

I've recently got a Dell XPS L702X laptop and I was trying to get Nvidia Optimus GPU switching to work in Ubuntu 12.04, through Bumblebee but when running "optirun", I was getting this error:

[ERROR]Cannot access secondary GPU - error: XORG NVIDIA(0): No display devices found for this X screen.

After trying various different solutions available on the Bumblebee wiki and other websites, I've finally found one that worked, so I though I'd share it with you, in case you encounter the same issue as me.