I'm trying to achieve near perfect black levels using MPEG-4 AVC's h264 encoding but no matter what settings I try I can't get good black levels They always come out to be an off-black or really dark gray. I have some borders (and chopping them off is not an option nor is adding black borders) that are originally pitch black - perfectly black 000000. I use these videos on a black website so it stands out.
I encoded a file using XVID instead just to make sure Avidemux could achieve the black levels I wanted at all, period, and it was successful. I'm going to show you the results. On the left will be normal and the on the right will be with the lightness increased to exaggerate the effect to make sure you understand I'm not just making this up.
Here's the capture using xvid which is successful at matching pure black:

And here's another snippit of a file encoding with h264 or x264 or whatever it's using:

I added a small perfect column of black to the left of these images to give you some context of what it should be matching.
I know this is a small nitpick but I really want to do this correctly. How do I achieve the black levels I desire using h264 and Avidemux?