Obtaining a nonsingular two-dimensional cloak of complex shape from a perfect three-dimensional cloak