@ juliansader,
For JS_Composite() docs says, "If dstw or dsth is -1, the bitmap will be stretched to fill the width or height of the window", but using -1 doesn't work. Finally googled the function name and found a script by Sexan and noticed he's using 1,1 for these params. So I tried 1,1 instead of -1,-1 and now my code is working as expected.
Maybe its just me but the docs seems confusing, shouldn't it say, "If dstw or dsth are 1" (a positive one) instead of -1, or the API function in the extension needs updating?