Three Americans, including a man who was facing the death penalty, have been freed by China in a prisoner swap with the US.