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.

Note: this has only been tested with Dell XPS L702X and may or may not work for other laptops.

Get Bumblebee working in Ubuntu 12.04 (tested on Dell XPS L702X)

1. Firstly, install Bumblebee if it's not already installed. If you've messed with the Bumblebee config files, it's probably best to revert them to their default values - you can do this by purging and then installing Bumblebee back:

sudo apt-get purge bumblebee
sudo apt-get install bumblebee

2. Now, to apply the workaround for getting Bumblebee to work:

You can see if you have the "nvidia-current" or "nvidia-current-updates" driver installed by searching for "nvidia-current" in in Synaptic.

If you are using the nvidia-current driver, copy/paste the following code in a terminal, as a single command (select all the code and paste it):

After you're done, restart your computer and run "optirun glxspheres" in a terminal to see if Bumblebee / Nvidia Optimus is working correctly - you shouldn't see the error anymore and instead, something like this should be displayed: