Regularity results for a class of obstacle problems