Bill Gates said he intends to keep working for at least another two decades if his health allows—following in the footsteps of Warren Buffett.