Mitigation of readout errors in near-term quantum devices by classical post-processing based on detector tomography