I heard the ATIS at San Carlos (SQL) "1100 scattered," got clearance from the tower, and departed on runway 30 for a right downwind in a rented 172. At 700 feet I could see I was about to enter some clouds unless I started a hard climb, so I pitched for Vx, and started my crosswind and downwind turns. The tower told me to switch to Bay Approach. As I was switching the radio and continuing to climb, I realized I was headed into the path of a 727 landing at SFO. I was at 2000 feet and had busted SFO "B" airspace. I started a right turn and rapid descent out of the "B." I contacted approach, and they asked "are you the aircraft that just entered Bravo over SQL without a clearance?" I said that I probably was, and was told to call a phone number on the ground. The rest of the flight was uneventful, and when I spoke to the ATC supervisor, I confessed, explained my attempt to remain clear of clouds, and we talked about how the better thing to do would have been getting a Special VFR and departing on the downwind at TPA (800 feet). He was polite and understanding, and helped me learn a valuable lesson, that "scattered" clouds aren't scattered if you fly right into them. Fortunately he accepted my safety decision and did not ask for any of my license information. As a 100 hour pilot, I had not learned to judge clouds accurately.