Solvepol: A reduction pipeline for imaging polarimetry data