OK, won’t let me upload the blend, so a quick setup.
Create the cube, a light and the plane. The plane will be the shadow catcher. Assign a material to the plane as follows (NB: You can set up your diffuse/glossy however you want. The only part specific to the shadow catcher is the transparent mix and light path):
The transparent part prevents the plane reflecting in your other objects.
Move the cube to layer 1, the plane to layer 2, and the light to both layer 1 and 2. Enable layer 1 and 2 for render. Enable the shadow catcher plugin from the tool shelf, and the background if you need it.
NB. In the compositing node setup the Multiply node after the RGB curves is where you set the background. If you change the alpha on the unconnected colour you can get a complete alpha mask. Plugin a background image and it will composite on top of the image.
There are some settings on the tool shelf and in the compositor window (toolshelf for background image, and compositing to adjust the strength and blur of the shadows).
Also, video for usage from an old version at https://www.youtube.com/watch?v=M2LgAytYRts. Stuff I say I’ll automate in the video has since been automated, and the tools in the compositor simplify tweaking the final look. You need to ensure that the compositor nodes button is selected for the tools to have any effect.