Add some mime encoding/decoding functions and tests