How to use arbitrary measuring devices to perform almost perfect measurements