A generalized canonical formalism and quantization of reducible gauge theories