code: public static byte[] getBytes(long val, long size) {
          byte[] res = new byte[(int) size];
          long bv = val;
          for (int i = (int) size - 1; i >= 0; --i) {
              res[i] = (byte) (bv & 0xFF);
              bv >>= BIT_IN_BYTE;
          }
          return res;
      }
docs: method to encode long as byte array of given size
  
  @param val
  - value to encode
  @param size
  - size
  @return - byte array