Third quantization: a general method to solve master equations for quadratic open Fermi systems