Use PlotPoints option in ContourPlot to get smoother contours.
levelsetwithbounds1[e_, k_, M_] := Module[{k1, set1}, k1 = k;
set1 = ContourPlot[e == k1, {x, -M, M}, {y, -M, M}, Axes -> True, Mesh -> Full, PlotPoints -> 50]; Return[set1]];
levelsetwithbounds1[x^3 - y, 30, 40]
or:
MaxRecursion option in ContourPlot to get refine the surface.
levelsetwithbounds2[e_, k_, M_] := Module[{k1, set1}, k1 = k;
set1 = ContourPlot[e == k1, {x, -M, M}, {y, -M, M}, Axes -> True, Mesh -> Full, MaxRecursion -> 6]; Return[set1]];
levelsetwithbounds2[x^3 - y, 30, 40]
Regards,MI