General approach to transient flows of rarefied gases through long capillaries