Modeling the chemistry of planetary atmospheres: implications for the bulk compositions of giant planets