Quasilocal first law for black hole thermodynamics