As long as you use styrofoam that's not coated in anything (such as mildew resistant, etc.), it's safe. The pink insulation foam is safe. If you're really worried about it, you can pick up cheap styrofoam coolers and cut those down - they are specifically labelled as "food safe" which translates to aquarium safe.
I made my own styrofoam background for my tank, and it turned out very nice. I used just plain white insulation foam sheets, covered it in latex-based drylok with cement tints, and then coated the whole thing in clear Plasti Dip for extra durability. The tricky part is you have to reallllly stick it down well with aquarium safe silicone because styrofoam is so buoyant - even covered in cement.
This is my background in a 54 gallon corner bowfront. I don't have a better picture yet because I'm not quite done with the plant-scape. I have a ton more plants in there now, but I'm not happy yet with the arrangement.