This is caused by a condition called Blossom End Rot. One of the contributing factors is a deficiency of Calcium in the plant. We like to add lime to the soil when planting Tomatoes to supply them with needed Calcium. However in spite of doing this you may still get Blossom End Rot. During the growing season you can spray the entire plant with Ferti-lome Yield Booster (which contains Calcium chloride solution) to prevent this condition from ruining the fruit.