I've been trying to wrap my head around Walter Lewin's lecture on Gauss's law and electric flux and I can't go on without thoroughly getting this first. I think I've understood the electric flux part, but then he went on to explain Gauss's law this way: imagine a point charge with electric field around it $$E=\frac{q}{4\pi\varepsilon_0r^2}.$$ If we draw a spherical closed surface around the charge, the flux through the sphere is: $$ flux = \iint E \cos(\theta) dA,$$ where $E$ is on the surface, and $\theta$ is the angle between $E$ and the surface vector. Since $\cos(\theta)=1$ for all points, and $A=4\pi r^2$, then the flux is $q/\varepsilon_0$ (or how I understood it, the decrease of the field strength $E$ is offset perfectly by the increase of area $A$).
He then says that this law holds true for any closed surface. How is this possible? For a cubical surface, the $\cos(\theta)$ is not going to be $1$ everywhere, and the area is $24r^2 \implies \frac{q}{4\pi\varepsilon_0 r^2} \times 24r^2 = \frac{6q}{\pi \varepsilon_0}$? Why are cubes gaussian surfaces?