hmm best way I also use is to generate osm poly file by
JSOMresult is OSM xml file. To convert to required poly file, use attached perl scripts

syntax is
perl __poly2osm.pl afghanistan.poly > afghanistan.osm
and opposite when you want to convert from OSM to poly
JSOM also allow to load GPX file directly, so you should not have any problems with it
