Transparent rendered object over tracked background
The default nodes created when you solve a scene with motion tracking and hit "Setup Tracking Scene" don't really work in all cases. 

The problem is that the 3D scene with the transparent background is not added using an Alpha Over node on top of the background.

The basic nodes you need looks more like this:



Or maybe even something like this: