STOCK PURCHASE AGREEMENT dated as of August 29, 1997, by and among TSMD ACQUISITION CORP., WATKINS-JOHNSON COMPANY