cookies = http.cookiejar.CookieJar()
opener = urllib.request.build_opener(urllib.request.HTTPRedirectHandler(), urllib.request.HTTPCookieProcessor(cookies))
contents = open(upfile, 'rb').read()
imgparams = [('action', b'upload'), ('filename', bytes(filename, encoding = 'utf8')), ('text', b'Powered by Python'), ('token', bytes(etoken, encoding = 'utf8')), ('file', contents)]
imgparams = enc_multipart(imgparams)
ctype, imgdata = imgparams
imageup = urllib.request.Request('http://tlwiki.org/api.php?&bot', imgdata, {'Content-Type': ctype})
opener.open(imageup)