Fix two bugs related to opencl context.
1. As getDevice will implicitly call setDevice, in getContext we should not need to call it again.
2. Fix an incorrect type casting.
Merge pull request #982 from pengx17:2.4_fix_two_bugs