I want to find the moment of inertia about the axis perpendicular to the base and passing through the center of mass (z-axis?). Mass is M and height is H and base has sides $a$.
I know I can take a slab of the pyramid and take the volume of the slab dv = $b^2$ x dH where $b$ is the length of the slab and dH is the height and then get the mass dm = $\rho$ x dv = $\rho$ x $b^2$ x dh. I'm stuck at this point and would appreciate any help.
The basic integral you need is $\displaystyle I=\int_Q r^2 \, dm$. The problem with your approach so far is that the slab is not equidistant from the axis of rotation, so that $r^2$ varies over your slab. You need to take a chunk where you can approximate the $r^2$ as constant over your chunk. That means a chunk $dV=dx\,dy\,dz$. So here, $dm=\rho\,dx\,dy\,dz$, where you can get $\rho=M/V$, assuming constant density. Then you need to set up your integral as $$I=\rho\iiint_Qr^2\,dx\,dy\,dz.$$ If you draw some careful pictures, you can find out how $r^2$ varies with respect to $x,y,$ and $z$, and you can get your limits for each of the variables. Can you proceed from here?