For example I want to use the design generated by this code as the base of a pyramid as well as other iterations of the design
carpet[n_] := Nest[ArrayFlatten[{{#, #, #}, {#, 0, #}, {#, #, #}}] &, 1, n]
ArrayPlot[carpet[2], PixelConstrained -> 40]

For example I want to use the design generated by this code as the base of a pyramid as well as other iterations of the design
carpet[n_] := Nest[ArrayFlatten[{{#, #, #}, {#, 0, #}, {#, #, #}}] &, 1, n]
ArrayPlot[carpet[2], PixelConstrained -> 40]

Perhaps something like this:
i = ImageResize[ColorNegate@Image[carpet[2]], 300]
j = Join[{#, 0} & /@ PixelValuePositions[i, 0.], {#, 1} & /@ PixelValuePositions[i, 1.]];
g = Interpolation[j, InterpolationOrder -> 0];
RegionPlot3D[z < x + y && g[x, y] == 0, {x, 1, 300}, {y, 1, 300}, {z, 1, 300},
PlotPoints -> 50, Mesh -> None]

or perhaps
i = ImageResize[ColorNegate@Image[carpet[2]], 20];
o = Flatten /@ Tuples[{PixelValuePositions[i, 0.], Range@20}];
Graphics3D[{EdgeForm[None], (Cuboid[{##}] & @@@ o)}, Boxed -> False]

s = 100;
i = ImageResize[ColorNegate@Image[carpet[2]], s];
t = Table[Thread[{Select[PixelValuePositions[i, 0.], Max[Abs[(s + 1)/2 - #] & /@ #] < j &], j}],
{j, IntegerPart[(s + 1)/2]}];
Graphics3D[{EdgeForm[None], Cuboid @@ {#} & /@ Flatten /@ Flatten[t, 1]}]

Building off of Dr. belisarius's answer: is this what you're looking for?
n = 20;
i = ImageResize[ColorNegate@Image[carpet[2]], n]
pixpos = PixelValuePositions[i, 0.];
pyramids = Pyramid[{Append[# + {1/2, 1/2}, 0], Append[# + {1/2, -1/2}, 0],
Append[# + {-1/2, -1/2}, 0], Append[# + {-1/2, 1/2}, 0],
{(n + 1)/2, (n + 1)/2, -n}}] & /@ pixpos;
Graphics3D[{EdgeForm[None], pyramids}]

There's probably a more efficient way of doing this rather than using all those Append's, but I have to run and can't improve this just now.
Append instead of AppendTo.
– Michael Seifert
Apr 04 '16 at 13:35
n represents the number of "pixels" in the base. You'll need to increase it if you want to do a higher-resolution design on the base. For carpet[3], carpet[4], and carpet[5], you'll probably want to set $n$ equal to $3^3$, $3^4$, or $3^5$ respectively. This code may start to get pretty unwieldy for the last of these.
– Michael Seifert
Apr 04 '16 at 14:13
mm = MengerMesh[2];
meshcoords = Append[Append[0] /@ #, Append[1] @ Mean @ #] & @ MeshCoordinates[mm];
prims = Pyramid[Append[Length @ meshcoords] @ #] & /@ MeshCells[mm, 2][[All, 1]];
mengerPyramid = MeshRegion[meshcoords, prims, PlotTheme -> "Polygons"]
Use mm = MengerMesh[3] above to get
TextureandVertexTextureCoordinates. Related. – Martin Ender Mar 30 '16 at 14:12