Data reduction pipeline for the Hi-GAL survey