A model for the optical properties of porous grains