Fix encoding error under 1.9.3

Also add timeout and socket requires that are needed in 1.9.3